package cn.hk.vaccination.service.impl;

import cn.hk.common.entity.PlanTypeConstant;
import cn.hk.vaccination.domain.VaccinesPlanCommon;
import cn.hk.vaccination.domain.vo.VaccinationVo;
import cn.hk.vaccination.mapper.VaccinesPlanCommonMapper;
import cn.hk.vaccination.service.DeptVaccinesStockService;
import cn.hk.vaccination.service.PlanCommonInoculationService;
import cn.hk.vaccination.service.VaccinesPlanCommonService;
import cn.hutool.core.lang.Console;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 普通人接种计划关联表 服务实现类
 * </p>
 *
 * @author xu
 * @since 2023-03-10
 */
@Service
public class VaccinesPlanCommonServiceImpl extends ServiceImpl<VaccinesPlanCommonMapper, VaccinesPlanCommon> implements VaccinesPlanCommonService {
    @Autowired
    private PlanCommonInoculationService planCommonInoculationService;

    @Autowired
    private DeptVaccinesStockService deptVaccinesStockService;

    @Autowired
    private VaccinesPlanCommonMapper vaccinesPlanCommonMapper;

    @Override
    public  List<VaccinationVo>  getVaccinationVoListByCommon( Integer age, Integer gender, Long deptId) {
        //存放vo
        List<VaccinationVo> vaccinationVoList = new ArrayList<>();

        try {
              vaccinationVoList = vaccinesPlanCommonMapper.selectListByAgeAndgenderAndDeptId(age, gender,deptId);

            for (VaccinationVo vaccinationVo : vaccinationVoList) {
                vaccinationVo.setPlanType(PlanTypeConstant.COMMONVACCINATE);
                if (vaccinationVo.getAdequate() == null){
                    vaccinationVo.setAdequate(2);
                }
            }

        }catch (Exception e) {
            Console.error("发生了异常", e);
        }
        return vaccinationVoList;

    }
}
